ccR.Add_Rotation(
	2, 
	"Ankhys_BASIC_Frost_DK",
	"BASIC Rotation\n\nMade by Ankhy"
)
function Ankhys_BASIC_Frost_DK()
	if (ccR.Player.IsInCombat() or (ccR.Player.IsInGroup() and ccR.Target.IsInCombat())) and ccR.Target.Is.Attackable() then
		if ccR.Player.Has.Glyph(59332) and not ccR.Player.Has.Buff("Breath of Sindragosa") then
			if not ccR.Player.HasTalent("Necrotic Plague") and not ccR.Target.HasMyDebuff("Blood Plague") and ccR.Spell.IsReady("Outbreak") then ccR.Cast.Attack("Outbreak") end
			if not ccR.Player.HasTalent("Necrotic Plague") and not ccR.Target.HasMyDebuff("Frost Fever") and ccR.Spell.IsReady("Outbreak") then ccR.Cast.Attack("Outbreak") end
			if ccR.Player.HasTalent("Necrotic Plague") and not ccR.Target.HasMyDebuff("Necrotic Plague") and ccR.Spell.IsReady("Outbreak") then ccR.Cast.Attack("Outbreak") end	
		else	
			if not ccR.Player.HasTalent("Necrotic Plague") and (not ccR.Target.HasMyDebuff("Blood Plague") or ccR.Target.DebuffDuration("Blood Plague","<", 3)) and ccR.Spell.IsReady("Outbreak") then ccR.Cast.Attack("Outbreak") end
			if not ccR.Player.HasTalent("Necrotic Plague") and (not ccR.Target.HasMyDebuff("Frost Fever") or ccR.Target.DebuffDuration("Frost Fever","<", 3)) and ccR.Spell.IsReady("Outbreak") then ccR.Cast.Attack("Outbreak") end
			if ccR.Player.HasTalent("Necrotic Plague") and (not ccR.Target.HasMyDebuff("Necrotic Plague") or ccR.Target.DebuffDuration("Necrotic Plague","<", 1)) and ccR.Spell.IsReady("Outbreak") then ccR.Cast.Attack("Outbreak") end	
			if not ccR.Player.HasTalent("Necrotic Plague") and (not ccR.Target.HasMyDebuff("Blood Plague") or ccR.Target.DebuffDuration("Blood Plague","<", 3)) and ccR.Spell.IsReady("Unholy Blight") then ccR.Cast.Spell("Unholy Blight") end
			if not ccR.Player.HasTalent("Necrotic Plague") and (not ccR.Target.HasMyDebuff("Frost Fever") or ccR.Target.DebuffDuration("Frost Fever","<", 3)) and ccR.Spell.IsReady("Unholy Blight") then ccR.Cast.Spell("Unholy Blight") end
			if ccR.Player.HasTalent("Necrotic Plague") and (not ccR.Target.HasMyDebuff("Necrotic Plague") or ccR.Target.DebuffDuration("Necrotic Plague","<", 1)) and ccR.Spell.IsReady("Unholy Blight") then ccR.Cast.Spell("Unholy Blight") end
			if not ccR.Player.HasTalent("Necrotic Plague") and (not ccR.Target.HasMyDebuff("Blood Plague") or ccR.Target.DebuffDuration("Blood Plague","<", 3)) and ccR.Spell.IsReady("Plague Strike") then ccR.Cast.Attack("Plague Strike") end
			if not ccR.Player.HasTalent("Necrotic Plague") and (not ccR.Target.HasMyDebuff("Frost Fever") or ccR.Target.DebuffDuration("Frost Fever","<", 3)) and ccR.Spell.IsReady("Plague Strike") then ccR.Cast.Attack("Plague Strike") end
			if ccR.Player.HasTalent("Necrotic Plague") and (not ccR.Target.HasMyDebuff("Necrotic Plague") or ccR.Target.DebuffDuration("Necrotic Plague","<", 1)) and ccR.Spell.IsReady("Plague Strike") then ccR.Cast.Attack("Plague Strike") end
		end
		if ccR.Target.Count(15) >= 3 then
			if ccR.Spell.CanAttack(FROST_STRIKE) and ccR.Player.Runic_Power() >= 75 then ccR.Cast.AF.Attack(FROST_STRIKE)
			elseif ccR.Spell.CanAttack(HOWLING_BLAST) then ccR.Cast.AF.Attack(HOWLING_BLAST)
			elseif ccR.Spell.CanAttack(FROST_STRIKE) then ccR.Cast.AF.Attack(FROST_STRIKE)
			elseif ccR.Spell.CanAttack(PLAGUE_STRIKE) then ccR.Cast.AF.Attack(PLAGUE_STRIKE)
			end
		end		
			if OffhandHasWeapon() then
				if ccR.Target.Is.Attackable() then
					if not ccR.Player.HasBuff("Conversion") and ccR.Spell.CanAttack("Frost Strike") and ccR.Player.Runic_Power() >= 75 then ccR.Cast.AF.Attack("Frost Strike")
					elseif ccR.Spell.CanAttack(FROST_SOUL_REAPER) and ccR.Target.Health() <= 35 then ccR.Cast.AF.Attack(FROST_SOUL_REAPER)
					end
					if ccR.Spell.Is.Ready("Blood Tap") and ccR.Player.Has.Talent("Blood Tap") and (ccR.Player.Has.Buff("Blood Charge") and ccR.Player.BuffStacks("Blood Charge") >= 5 and ccR.Spell.Is.Ready("Soul Reaper") and ccR.Target.Health() <= 45 and not ccR.Spell.CanAttack("Soul Reaper")) then if (not select(3, GetRuneCooldown(1)) and not select(3, GetRuneCooldown(2))) or (not select(3, GetRuneCooldown(3)) and not select(3, GetRuneCooldown(4))) or (not select(3, GetRuneCooldown(5)) and not select(3, GetRuneCooldown(6))) then ccR.Cast.Spell("Blood Tap") end end
					Plague_Leech()
					if ccR.Player.Has.Talent(NECROTIC_PLAGUE) then
						if ccR.Spell.CanAttack(OUTBREAK) and not ccR.Target.Has.MyDebuff(NECROTIC_PLAGUE_DEBUFF) then ccR.Cast.AF.Attack(OUTBREAK) end
						if ccR.Spell.CanAttack(HOWLING_BLAST) and not ccR.Target.Has.MyDebuff(NECROTIC_PLAGUE_DEBUFF) then ccR.Cast.AF.Attack(HOWLING_BLAST) end
						if ccR.Spell.CanAttack(PLAGUE_STRIKE) and not ccR.Target.Has.MyDebuff(NECROTIC_PLAGUE_DEBUFF) then ccR.Cast.AF.Attack(PLAGUE_STRIKE) end
					else
						if ccR.Spell.CanAttack(OUTBREAK) and (not ccR.Target.Has.MyDebuff(FROST_FEVER) or not ccR.Target.Has.MyDebuff(BLOOD_PLAGUE)) then ccR.Cast.AF.Attack(OUTBREAK) end
						if ccR.Spell.CanAttack(HOWLING_BLAST) and (not ccR.Spell.CanAttack(OUTBREAK) and not ccR.Target.Has.MyDebuff(FROST_FEVER)) then ccR.Cast.AF.Attack(HOWLING_BLAST) end
						if ccR.Spell.CanAttack(PLAGUE_STRIKE) and (not ccR.Spell.CanAttack(OUTBREAK) and not ccR.Target.Has.MyDebuff(BLOOD_PLAGUE)) then ccR.Cast.AF.Attack(PLAGUE_STRIKE) end
					end
					if ccR.Spell.Is.Ready("Blood Tap") and ccR.Player.Has.Talent("Blood Tap") and (ccR.Player.Has.Buff("Blood Charge") and ccR.Player.BuffStacks("Blood Charge") >= 5) then if (not select(3, GetRuneCooldown(1)) and not select(3, GetRuneCooldown(2))) or (not select(3, GetRuneCooldown(3)) and not select(3, GetRuneCooldown(4))) or (not select(3, GetRuneCooldown(5)) and not select(3, GetRuneCooldown(6))) then ccR.Cast.Spell("Blood Tap") end end
					Plague_Leech_Last_Resort()
					if not ccR.Player.HasBuff("Conversion") and ccR.Spell.CanAttack(FROST_STRIKE) and (ccR.Player.Has.Buff(KILLING_MACHINE) or ccR.Player.Runic_Power() >= 70) then ccR.Cast.AF.Attack(FROST_STRIKE)
					elseif ccR.Spell.CanAttack(HOWLING_BLAST) and ccR.Player.Has.Buff(FREEZING_FOG) then ccR.Cast.AF.Attack(HOWLING_BLAST)
					elseif ccR.Spell.CanAttack(HOWLING_BLAST) then ccR.Cast.AF.Attack(HOWLING_BLAST) 
					end
					if ccR.Var("Death_Strike") and ccR.Player.Health() <= ccR.Var("Death_Strike_Health") and ccR.Spell.CanAttack(DEATH_STRIKE) and ((ccR.Var("Death_Strike_InLFG") and (ccR.Player.Is.InDungeon() or ccR.Player.Is.InRaid() or ccR.Player.Is.Solo())) or (not ccR.Var("Death_Strike_InLFG") and ccR.Player.Is.Solo())) then ccR.Cast.AF.Attack(DEATH_STRIKE) else if ccR.Spell.CanAttack(OBLITERATE) then ccR.Cast.AF.Attack(OBLITERATE) end end
				end
			else
				if ccR.Target.Is.Attackable() then
					if ccR.Spell.IsReady(152280) and not ccR.Target.IsMoving() then ccR.Cast.AoE(152280, "target", 30, 8) end
					if not ccR.Player.HasBuff("Conversion") and ccR.Spell.CanAttack(FROST_STRIKE) and ccR.Player.Runic_Power() >= 75 then ccR.Cast.AF.Attack(FROST_STRIKE)
					elseif ccR.Spell.CanAttack(FROST_SOUL_REAPER) and ccR.Target.Health() <= 35 then ccR.Cast.AF.Attack(FROST_SOUL_REAPER)
					end
					Plague_Leech()
					if ccR.Spell.Is.Ready("Blood Tap") and ccR.Player.Has.Talent("Blood Tap") and (ccR.Player.Has.Buff("Blood Charge") and ccR.Player.BuffStacks("Blood Charge") >= 5 and ccR.Spell.Is.Ready("Soul Reaper") and ccR.Target.Health() <= 45 and not ccR.Spell.CanAttack("Soul Reaper")) then if (not select(3, GetRuneCooldown(1)) and not select(3, GetRuneCooldown(2))) or (not select(3, GetRuneCooldown(3)) and not select(3, GetRuneCooldown(4))) or (not select(3, GetRuneCooldown(5)) and not select(3, GetRuneCooldown(6))) then ccR.Cast.Spell("Blood Tap") end end
					if ccR.Player.Has.Talent(NECROTIC_PLAGUE) then
						if ccR.Spell.CanAttack(OUTBREAK) and not ccR.Target.Has.MyDebuff(NECROTIC_PLAGUE_DEBUFF) then ccR.Cast.AF.Attack(OUTBREAK) end
						if ccR.Spell.CanAttack(HOWLING_BLAST) and not ccR.Target.Has.MyDebuff(NECROTIC_PLAGUE_DEBUFF) then ccR.Cast.AF.Attack(HOWLING_BLAST) end
						if ccR.Spell.CanAttack(PLAGUE_STRIKE) and not ccR.Target.Has.MyDebuff(NECROTIC_PLAGUE_DEBUFF) then ccR.Cast.AF.Attack(PLAGUE_STRIKE) end
						if  ccR.Player.Is.InPVP() and not ccR.Target.HasMyDebuff("Chains of Ice") and ccR.Spell.IsReady("Chains of Ice") then ccR.Cast.AF.Attack("Chains of Ice") end	
					end
					if not ccR.Player.Has.Talent(NECROTIC_PLAGUE) then
						if ccR.Spell.CanAttack(OUTBREAK) and (not ccR.Target.Has.MyDebuff(FROST_FEVER) or not ccR.Target.Has.MyDebuff(BLOOD_PLAGUE)) then ccR.Cast.AF.Attack(OUTBREAK) end
						if ccR.Spell.CanAttack(HOWLING_BLAST) and (not ccR.Spell.CanAttack(OUTBREAK) and not ccR.Target.Has.MyDebuff(FROST_FEVER)) then ccR.Cast.AF.Attack(HOWLING_BLAST) end
						if ccR.Spell.CanAttack(PLAGUE_STRIKE) and (not ccR.Spell.CanAttack(OUTBREAK) and not ccR.Target.Has.MyDebuff(BLOOD_PLAGUE)) then ccR.Cast.AF.Attack(PLAGUE_STRIKE) end
						if  ccR.Player.Is.InPVP() and not ccR.Target.HasMyDebuff("Chains of Ice") and ccR.Spell.IsReady("Chains of Ice") then ccR.Cast.AF.Attack("Chains of Ice") end
					end
					if not ccR.Player.HasBuff("Conversion") and ccR.Spell.CanAttack(FROST_STRIKE) and ccR.Player.Runic_Power() >= 75 then ccR.Cast.AF.Attack(FROST_STRIKE) end
					if ccR.Player.HasBuff("Pillar of Frost") then UseInventoryItem(14) UseInventoryItem(13) end 
					if ccR.Spell.CanAttack(OBLITERATE) and ccR.Player.Has.Buff(KILLING_MACHINE) and ccR.Spell.CDDuration("Pillar of Frost") < 1 then ccR.Cast.Spell("Pillar of Frost") end
					if ccR.Spell.Is.Ready("Blood Tap") and ccR.Player.Has.Talent("Blood Tap") and (ccR.Player.Has.Buff("Blood Charge") and ccR.Player.BuffStacks("Blood Charge") >= 5) then if (not select(3, GetRuneCooldown(1)) and not select(3, GetRuneCooldown(2))) or (not select(3, GetRuneCooldown(3)) and not select(3, GetRuneCooldown(4))) or (not select(3, GetRuneCooldown(5)) and not select(3, GetRuneCooldown(6))) then ccR.Cast.Spell("Blood Tap") end end
					Plague_Leech_Last_Resort()
					if ccR.Spell.CanAttack(OBLITERATE) and ccR.Player.Has.Buff(KILLING_MACHINE) and ccR.Spell.CDDuration("Pillar of Frost") > 1 then ccR.Cast.AF.Attack(OBLITERATE) end
					if ccR.Var("Death_Strike") and ccR.Player.Health() <= ccR.Var("Death_Strike_Health") and ccR.Spell.CanAttack(DEATH_STRIKE) and ((ccR.Var("Death_Strike_InLFG") and (ccR.Player.Is.InDungeon() or ccR.Player.Is.InRaid() or ccR.Player.Is.Solo())) or (not ccR.Var("Death_Strike_InLFG") and ccR.Player.Is.Solo())) then ccR.Cast.AF.Attack(DEATH_STRIKE) else if ccR.Spell.CanAttack(OBLITERATE) and not ccR.Player.Has.Buff(KILLING_MACHINE) then ccR.Cast.AF.Attack(OBLITERATE) end end
					if ccR.Spell.CanAttack(FROST_STRIKE) and (not ccR.Player.Has.Buff(KILLING_MACHINE) or ccR.Player.BuffDuration("Killing Machine", "<=", 0.2)) then ccR.Cast.AF.Attack(FROST_STRIKE)
					elseif ccR.Spell.CanAttack("Icy Touch") and ccR.Player.Has.Buff(FREEZING_FOG) then ccR.Cast.AF.Attack("Icy Touch")
					elseif not ccR.Player.HasBuff("Conversion") and (not ccR.Player.Has.Buff(KILLING_MACHINE) or ccR.Player.BuffDuration("Killing Machine", "<=", 0.2)) and ccR.Spell.CanAttack(FROST_STRIKE) then ccR.Cast.AF.Attack(FROST_STRIKE)
					if ccR.Player.Is.InPVP() and not ccR.Target.HasMyDebuff("Chains of Ice") and ccR.Unit.Is.APlayer("target") 
						and not ccR.Target.HasBuff("Hand of Freedom")
						and not ccR.Unit.Is.Immune.To.Magic("target")
						and not ccR.Unit.Is.Immune.To.All("target")
						and ccR.Spell.IsReady("Chains of Ice") and ccR.Spell.CanAttack("Chains of Ice") then ccR.Cast.AF.Attack("Chains of Ice") end
					end
				end
			end
		end
	end	
	local function Plague_Leech()
	local vRunesDepleted = 0
	for i= 1, 6 do 
		local start, duration, runeReady = GetRuneCooldown(i)
		if not runeReady and start > 0 and start < GetTime()-(duration/2) then vRunesDepleted = vRunesDepleted + 1 end
		--if not runeReady then vRunesDepleted = vRunesDepleted + 1 end
	end 
	if ccR.Spell.Is.Ready(PLAGUE_LEECH)	 
	and vRunesDepleted >= 2
	then
		for x = 1, #ccR_Enemies_Within_44 do 
			local vUnit = ccR_Enemies_Within_44[x] 
			if (
					(not ccR.Unit.Is.Boss(vUnit) and (ccR.Unit.Has.MyDebuff(vUnit, FROST_FEVER) and ccR.Unit.Has.MyDebuff(vUnit, BLOOD_PLAGUE)) or ccR.Unit.Has.MyDebuff(vUnit, NECROTIC_PLAGUE_DEBUFF))
					or
					(ccR.Unit.Is.Boss(vUnit) and (ccR.Unit.Has.MyDebuff(vUnit, FROST_FEVER) and ccR.Unit.MyDebuffDuration(vUnit, BLOOD_PLAGUE, "<=", 10)) or ccR.Unit.MyDebuffDuration(vUnit, NECROTIC_PLAGUE_DEBUFF, "<=", 10))
				)
			and ccR.Spell.CanAttack(PLAGUE_LEECH, vUnit) 
			and ccR.Player.Is.Facing(vUnit)
			then 
				ccR.Cast.Attack(PLAGUE_LEECH, vUnit)
			end
		end
	end
end
local function Plague_Leech_Last_Resort()
	local vRunesDepleted = 0
	for i= 1, 6 do 
		local start, duration, runeReady = GetRuneCooldown(i)
		if not runeReady and start > 0 and start < GetTime()-(duration/2) then vRunesDepleted = vRunesDepleted + 1 end
		--if not runeReady then vRunesDepleted = vRunesDepleted + 1 end
	end 
	if ccR.Spell.Is.Ready(PLAGUE_LEECH)	 
	and vRunesDepleted >= 2
	then
		for x = 1, #ccR_Enemies_Within_44 do 
			local vUnit = ccR_Enemies_Within_44[x] 
			if (ccR.Unit.Has.MyDebuff(vUnit, FROST_FEVER) and ccR.Unit.Has.MyDebuff(vUnit, BLOOD_PLAGUE) or ccR.Unit.Has.MyDebuff(vUnit, NECROTIC_PLAGUE_DEBUFF))
			and ccR.Spell.CanAttack(PLAGUE_LEECH, vUnit) 
			and ccR.Player.Is.Facing(vUnit)
			then 
				ccR.Cast.Attack(PLAGUE_LEECH, vUnit)
			end
		end
	end
end
